<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@include file="/common/common.jsp"%>
<%@include file="/common/skins/skin0/component.jsp" %>
<h:css href="/css/style1/style-custom.css"/>
<%--
- Author(s): pengweiling
- Date: 2012-07-06 08:57:21
- Description:
--%>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>
      房间预订
    </title>
    <script>
      //配置参数
      <% int ic = 0; %>
      gCfg = {
      <l:iterate property="cfg" id="id1">
         <% if (ic > 0){%>
         ,
         <%} %>
         '<b:write property="parameterCode" iterateId="id1"/>':'<b:write property="parameterValue" iterateId="id1"/>'
         <%ic++; %>
      </l:iterate>
      };
      
      //折扣规则
      <%ic=0; %>
      gRules = [
         <l:iterate property="rules" id ="id2">
         <% if (ic > 0){%>
         ,
         <%} %>
         {
           cCategory:'<b:write property="ccategory" iterateId="id2"/>',
           ndaysfrom:<b:write property="ndaysfrom" iterateId="id2"/>,
           ndaysto:<b:write property="ndaysto" iterateId="id2"/>,
           nratediscount:<b:write property="nratediscount" iterateId="id2"/>
         }
         <%ic++; %>
         </l:iterate>
      ];
    </script>    
    
<%
  String ua = request.getHeader( "User-Agent" );
  boolean isMSIE = ( ua != null && ua.indexOf( "MSIE" ) != -1 );
  if (isMSIE==true){

%>
<script type="text/javascript" src="OrderMgr/script/json2.js"></script>  
  
<%} %>  
    <script type="text/javascript" src="commonPick/script/utils.js"></script>    
    <script type="text/javascript" src="OrderMgr/script/order.js"></script>

  </head>
  <body>             
    <e:datasource name="weordertasks" type="entity" path="com.hms.OrderMgr.order.WeOrdertasks" />
    <h:form name="data_form" action="com.hms.OrderMgr.OrderMgr.flow" method="post" onsubmit="return submitDatacell(this);">
      <h:hidden property="weordertasks/iorderid" />
      <input type="hidden" id="depositSaved" value="N">
      <input type="hidden" name="_eosFlowAction" value="insertSubmit" >
      <h:hiddendata property="criteria" />
      <h:hidden property="page/begin"/>
      <h:hidden property="page/length"/>
      <h:hidden property="page/isCount"/>
      <dataform id= "efa30c85-dbed-4340-a754-267fa9a49981">
          <table align="center" border="0" width="100%" class="form_table">
            <tr>
               <td class="form_label">
                  订单编号
               </td>
              <td colspan="5" style="color:blue">
                <b:write property="weordertasks/corderno"/>
              </td>               
            </tr>
            <tr>
              <td class="form_label">
                预订人
              </td>
              <td colspan="1">
                <h:text property="weordertasks/cbookname" style="width:200px;" validateAttr="allowNull=false"/><font style="color:red">*</font>
              </td>
              <td class="form_label">
                预订人手机
              </td>
              <td colspan="1">
                <h:text property="weordertasks/cbooktel"  style="width:200px;" />
              </td>
              <td class="form_label">
                预定会员
              </td>
              <td colspan="1">
                <w:lookup property="weordertasks/cbookmemberid"  
                          displayProperty="weordertasks/memberName"
                          style="width:200px;" 
                          dialogTitle="选择会员"
                          allowInput="false"
                          lookupUrl="com.hms.commonPick.WeMemberSelect.flow"/>

              </td>
            </tr>
            <tr>
              <td class="form_label">
                是否送机
              </td>
              <td colspan="1">
                <h:switchCheckbox checkedValue="Y" property="weordertasks/bisseeoff" uncheckedValue="N" />
              </td>
              <td class="form_label">
                送机时间
              </td>
              <td colspan="1">
                <w:date property="weordertasks/dseeoffdate" style="width:200px;"  format="yyyy-MM-dd HH:mm:ss" />
              </td>
              <td class="form_label">
                送机目的地
              </td>
              <td colspan="1">
                <h:text property="weordertasks/cseeoffaddress" style="width:200px;"/>
              </td>
            </tr>
            <tr>
              <td class="form_label">
                客人来源
              </td>
              <td colspan="1">
                <input type="hidden" name="weordertasks/csourcename" value = "WalkIn" />
                直接入住
              </td>
              <td class="form_label">
                来源说明
              </td>
              <td colspan="3">
                <h:text property="weordertasks/csoucedescription" style="width:100%;" />
              </td>
            </tr>            
            <tr>
              <td class="form_label">
                总金额
              </td>
              <td colspan="1">
                <input type="text" id="txtPriceAmt" style="width:200px;" readonly="true"  />
                <input type="hidden" id="txtOriginAmt"/>
                <input type="hidden" id="txtDiscount"/>
                <input type="hidden" id="txtPrepayAmt"/>
                <input type="hidden" id="txtCommision"/>                
                <input type="hidden" name="weordertasks/npaypercent" id="txtPrepayPercent" value="1"/>
              </td>            
              <td class="form_label">
                付款方式
              </td>
              <td colspan="1">
                <d:select property="weordertasks/cpaymenttype" style="width:200px;" nullLabel="请选择" dictTypeId="HMS_PAYMENT_TYPE" />
              </td>
              <td class="form_label">
                付款摘要
              </td>
              <td colspan="1">
                <h:text property="weordertasks/cpaymentdescription" style="width:100%;"/>
              </td>
            </tr>
            <tr>
              <td class="form_label">
                备注
              </td>
              <td colspan="5">
                <h:textarea property="weordertasks/cdescription" style="width:100%;" />
              </td>
            </tr>
            <tr class="form_bottom">
              <td colspan="6">
                <input type="submit" value="保存" class="button" onsubmit="return submitDatacell(this);">
              </td>
            </tr>
          </table>
      </dataform>
      
      <w:layout height="70%" type="vertical" width="100%">
         <w:layoutPanel height="20%" width="100%">
            <w:layout height="100%" type="horizontal" width="100%">
              <w:layoutPanel width="60%" height="100%"> 
                 <r:datacell height="250" pageSize="1000" entityType="com.hms.OrderMgr.order.WeGres" id="gress" isCount="false" readonly="false" submitXpath="weordertasks/gress" width="100%" xpath="weordertasks/gress">
                   <r:toolbar location="top" tools="edit:add del"/>
                   <r:field fieldName="roomno" label="房号">
                     <w:lookup lookupUrl="com.hms.commonPick.WeRoomSelect.flow"
                               dialogTitle="选择房间"
                               allowInput="false"
                               onReturnFunc="setRoomId"
                     />
                   </r:field>
                   
                   <r:field fieldName="arrorigdate" label="抵店日期" nullText="必须输入" width="126">
                     <w:date format="yyyy-MM-dd HH:mm:ss" />
                   </r:field>
                              
                   <r:field fieldName="deporigdate" label="离店日期" nullText="必须输入" width="126">
                     <w:date format="yyyy-MM-dd HH:mm:ss" />
                   </r:field>
                              
                   <r:field fieldName="daycount" label="房晚数" onRefreshFunc="getDayCount" width="95">
                   </r:field>
                      
                   <r:field fieldName="daycount" label="状态" onRefreshFunc="getDayCount" width="95">
                   </r:field>     
                 </r:datacell>
              </w:layoutPanel>
              
              <w:layoutPanel width="40%" height="100%">
                <r:datacell pageSize="1000" id="grdSchedule" height="250"  width="100%" linkId="gress" linkField="schedules">
                   <r:toolbar location="top" tools="edit:refresh"/>
                   <r:field fieldName="dbusinessdate" label="入住日期"></r:field>
                   <r:field fieldName="nrate" label="房价/晚"></r:field>                                                      
                </r:datacell>                
              </w:layoutPanel>
            </w:layout>
         </w:layoutPanel>
         <w:layoutPanel height="80%" width="100%">         
           <w:tabPanel bodyStyle="" defaultTab="tabEntry" height="100%" id="pgInfo" titleStyle="" width="100%">              
              <w:tabPage cache="true" id="tabEntry" tabType="div" title="入住信息">
                <%@include file="/OrderMgr/EntryInfo.jsp" %>
              </w:tabPage> 
              <w:tabPage cache="true" id="tabBill" tabType="div" title="账单">
                <%@include file="/OrderMgr/Bill.jsp" %>
              </w:tabPage> 
           </w:tabPanel>
         </w:layoutPanel>
      </w:layout>

      
    </h:form>
    <script>
      function submitDatacell(frm) {
        if ($id("depositSaved").value == "N"){//收取房费和押金
           
           if (getDespositAndRate(true) == false){
              return false;
           }
        }
        
        if (checkForm(frm)) {
          var dcell = $id('gress'); 
          //dcell.submitAllByHidden();
          dcell.submitModifyByHidden();
          return true;
        }
        $id("depositSaved").value = "N";
        return false;
      }
      
      $id("gress").afterAdd = synGresAdd;
      $id("gress").afterDel = afterGressDelete;
      $id("gress").afterEdit = synGresEdit;
      $id("gress").afterSelectRow = showGressDetail;
      
      //line grid event
      $id("grdSchedule").afterAdd = sumAmount;
      $id("grdSchedule").afterDel = sumAmount;
      $id("grdSchedule").afterEdit = sumAmount;

      
      var func = $id("gress").loadData;
      $id("gress").loadData = function(){
        var xmlZone = document.getElementById(this.id + "_xml");
        this.dataXML = xmlZone ? xmlZone.innerHTML : null;
        var xmlDom;
        if (this.dataXML && this.dataXML !== "<json/>") {
            this.dataset = Dataset.create(this.dataXML, this.xpath);
            xmlDom = createXmlDom();
            xmlDom.loadXML(this.dataXML);
            var pagecond = xmlDom.selectSingleNode("/root/data/page");
            this.freshPagePilot(pagecond);
            initGress();    
            return
        }
        if (this.onLoadData() !== false) {
            if (!this.queryAction) return;
            var ajax = new HideSubmit(this.queryAction),
                param = this.getQueryForm();
            if (this.queryParam) param += this.queryParam;
            if (this.pageParam) param += this.pageParam;
            if (this.initParamFunc) {
                try {
                    param += eval(this.initParamFunc + "()")
                } catch(e) {
                    $handle(e)
                }
            }
            if (param == "") param = null;
            if (this.paramFormId) {
                var form = $id(this.paramFormId);
                if (form) for (var i = 0; i < form.elements.length; i++) {
                    var elem = form.elements[i];
                    if (elem.name) ajax.addParam(elem.name, getElementValue(elem))
                }
            }
            if (this.paramList) for (i = 0; i < this.paramList.length; i++) {
                elem = this.paramList[i];
                if (elem) ajax.addParam(elem.key, elem.value)
            }
            ajax.loadData(param);
            xmlDom = ajax.retDom;
            this.dataset = Dataset.create(xmlDom, this.xpath, this.getSubmitXpath());
            pagecond = xmlDom.selectSingleNode("/root/data/page");
            this.freshPagePilot(pagecond);
            this.afterLoadData(ajax)
        }
      }
      
      
      function setRoomId(args){         
         $id("gress").activeEntity.setPropertyByFieldName("iroomid", args[0]);
      }

      //开始刷新
      gressRefreshQueue();
      
      <l:equal property="_eosLastAccessAction" targetValue="insert">
        $id("txtPrepayPercent").value = gCfg.PREPAY_PERCENT + "";
      </l:equal>
      
    </script>
  </body>
</html>
